'use strict';
// Copyright 2016 4 28 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview
 * @author 454522799@qq.com (vincentxiaoxu debing)
 */

var moment = require('moment');
var _ = require('lodash');
var dataApi = require('../libs/dataApi');
var constantUtil = require('../util/constantUtil.js');

/**
 * 活动是否在活动期间
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.isOpen = function () {
    var isOpen = false;
    var start_time = constantUtil.value('get_soldier_open_time');
    var end_time = constantUtil.value('get_soldier_finis_time');
    var now_time = moment().unix();
    if (end_time > now_time && start_time <= end_time) {
        isOpen = true;
    }
    return isOpen;
};

/**
 * 累积活动配置表
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getConf = function () {
    var task_list = [];
    dataApi.get_soldier.each(function (task_conf, task_id) {
        task_list.push(+task_id);
    });
    return task_list;
};

/**
 * 获取士兵奖励配置
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getRewardList = function (soldier_id) {
    var conf = dataApi.get_soldier.findById(soldier_id);
    if (!conf) {
        console.error('not find seven soldier reward conf' + soldier_id);
        return;
    }
    return conf;
};
